<?php
namespace plugins\device\model;

use think\Db;
use think\Model;

/**
 * 设备模型
 */
class DeviceModel extends Model
{
    /**
     * 详情
     */
    public function getDetail($item){
        $item['add_time'] = date('Y-m-d H:i:s',$item['add_time']);
        $item['edit_time'] = date('Y-m-d H:i:s',$item['edit_time']);
        //地区名称
        $address_name = '-';
        $address = Db::name('address')->where('cri_code',$item['address_id'])->find();
        if(!empty($address)){
            $address_name = $address['cri_name'];
        }
        $item['address_name'] = $address_name;
        //状态
        $status_str = '离线';
        if($item['status'] == 1){
            $status_str = '在线';
        }
        $item['status_str'] = $status_str;

        return $item;
    }


}
